<?php
/* @var $this SuratKeluarController */
/* @var $model SuratKeluar */
/* @var $form CActiveForm */
?>
<?php $this->beginWidget('ext.widgets.XPanel', array('title' => 'Surat Keluar', 'width' => 900,'height' => 500)); 
?>
<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'surat-keluar-form',
	'enableAjaxValidation'=>true,
        //'enableClientValidation'=>true,
        'clientOptions'=>array(
                'validateOnSubmit'=>true,
                'beforeValidate' => 'js:beforeValidate'
        ),
)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>
    <table class="ma-table">
        <tbody>
	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'no_surat'); ?>
</td>
		<td><?php echo CHtml::activeTextField($model,'no_surat'); ?>
</td>
		<td><?php echo $form->error($model,'no_surat'); ?>
</td>
	</tr>
        
	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'id_tipe_surat'); ?>
</td>
		<td>
                    <?php 
                        echo CHtml::activeDropDownList(
                                $model,
                                'id_tipe_surat',
                                CHtml::listData(
                                        TipeSurat::model()->findAll(), 
                                        'id_tipe_surat', 
                                        'nama_tipe_surat'
                                        )
                                
                                ); 
                    ?>
                </td>
		<td><?php echo $form->error($model,'id_tipe_surat'); ?>
</td>
	</tr>
        
	<tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'judul_surat'); ?>
</td>
		<td><?php echo CHtml::activeTextField($model,'judul_surat'); ?>
</td>
		<td><?php echo $form->error($model,'judul_surat'); ?>
</td>
	</tr>
        <tr>
		<td class="labelfield" style="width:200px"><?php echo $form->labelEx($model,'isi_surat'); ?>
</td>           <td>
                    <?php
                    $this->widget('ext.xheditor.XHeditor',array(
                        'model'=>$model,
                        'modelAttribute'=>'isi_surat',
                        'showModelAttributeValue'=>true, // defaults to true, displays the value of $modelInstance->attribute in the textarea
                        'config'=>array(
                            'id'=>'xh1',
                            //'name'=>'xh',
                            'tools'=>'GStart,Cut,Copy,Paste,Pastetext,GEnd,Separator,GStart,Blocktag,Fontface,FontSize,Bold,Italic,Underline,Strikethrough,FontColor,BackColor,Removeformat,GEnd,Separator,GStart,Align,List,Outdent,Indent,GEnd,Separator,GStart,Link,Unlink,Img,Table,GEnd,Separator,GStart,Source,Preview,Fullscreen,GEnd', // mini, simple, fill or from XHeditor::$_tools
                            'width'=>'100%',
                            'height' => '500px'
                            //see XHeditor::$_configurableAttributes for more
                        ),
                    ));
            ?>
		<td><?php echo $form->error($model,'isi_surat'); ?>
</td>
	</tr>
        <tr>
		<td class="labelfield" style="width:200px">
                    <?php echo $form->labelEx($model,'draft'); ?>
                </td>
		<td>
                    <?php echo CHtml::activeCheckBox($model,'draft'); ?>
                </td>
		<td>
                    <?php echo $form->error($model,'draft'); ?>
                </td>
	</tr>
        <tr>
            <td colspan="3">
                
                <fieldset>
                    <legend>Persetujuan</legend>
                    Nama : 
                    <?php
                  $this->widget('ext.jui.CustomAutoComplete',
                            array(
                            'name'=>'no_identitas',
                            'source'=>$this->createUrl('Pegawai/autocomplete', array('by'=>'nama')),
                            'htmlOptions'=>array('placeholder'=>'Nama'),
                            'methodChain'=>'.data( "autocomplete" )._renderItem = function( ul, item ) {
                                return $( "<li></li>" )
                                    .data( "item.autocomplete", item )
                                    .append("<a>"+ item.value +  "("+ item.nip +") <br/><span style=font-size:10px>"+ item.jabatan +" ("+item.struktur_organisasi+")</span></a>")
                                    .appendTo( ul );
                            };',
                            'options'=>
                                array(
                                    'mustMatch'=> TRUE,
                                    'showAnim'=>'fold',
                                    'select'=>"js:function(hotel, ui) {
                                            addPegawai(ui);
                                            $('#no_identitas').val('');
                                        }"
                                        ),
                           
                            ));
                        ?>
                
                <div class="grid-view" id="pegawai-grid">
                            <div style="height:17px;border:0px;" class="x-panel-header-default x-horizontal x-panel-header-horizontal x-panel-header-default-horizontal x-top x-panel-header-top x-panel-header-default-top x-docked-top x-panel-header-docked-top x-panel-header-default-docked-top x-unselectable">                    
                                <span class="x-panel-header-text x-panel-header-text-default">                                            
                                </span>
                            </div>
                            <div class="ax-body-panel">
                                    <div style="clear: both;"></div>
                                    <table class="items" id="pegawai_table">
                                        <thead>
                                            <tr>
                                                <th id="pegawai-grid_c1">
                                                    Nama Pegawai
                                                </th>
                                                <th id="pegawai-grid_c2">
                                                    Unit
                                                </th>
                                                <th id="pegawai-grid_c6" class="lastcolumn">&nbsp;</th>
                                            </tr>
                                        </thead>
                                        <tbody>

                                        </tbody>
                                    </table>
                            </div><div title="/index.php?r=Pegawai" style="display:none" class="keys"><span>1</span><span>2</span><span>3</span><span>4</span><span>5</span></div>
                        </div>
                    Urutan Pegawai yang paling atas akan didahulukan terlebih dahulu, pastikan Urutan persetujuan sudah benar
                </fieldset>
                
            </td>
            
        </tr>

	<tr>
		<td></td>
                <td><?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('class'=>'ax-btn')); ?>
</td>
                <td></td>
	</tr>
        </tbody>
    </table>
<?php 
$this->endWidget(); 
?>

</div><!-- form -->
<?php $this->endWidget(); ?>